package com.ls.fw.hadoop.client.constant;

import java.util.ArrayList;
import java.util.List;

/**
 * datanode状态
 * <p></p>
 * @author ls 2013-11-4 下午03:25:40
 * @version V1.0   
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify by user: {修改人} 2013-11-4
 * @modify by reason:{方法名}:{原因}
 */
public enum StateType {
	NONE("","未知"),
	ACTIVE("active","激活")
	,STANDBY("standby","待命")
	;
	
	/** 枚举值 */
	private final String	code;
	
	/** 枚举描述 */
	private final String	message;
	
	/**
	 * 构造一个<code>JMXEnum</code>枚举对象
	 *
	 * @param code
	 * @param message
	 */
	private StateType(String code, String message) {
		this.code = code;
		this.message = message;
	}
	
	/**
	 * @return Returns the code.
	 */
	public String getCode() {
		return code;
	}
	
	/**
	 * @return Returns the message.
	 */
	public String getMessage() {
		return message;
	}
	
	/**
	 * @return Returns the code.
	 */
	public String code() {
		return code;
	}
	
	/**
	 * @return Returns the message.
	 */
	public String message() {
		return message;
	}
	
	/**
	 * 通过枚举<code>code</code>获得枚举
	 *
	 * @param code
	 * @return JMXEnum
	 */
	public static StateType getByCode(String code) {
		for (StateType _enum : values()) {
			if (_enum.getCode().equalsIgnoreCase(code)) {
				return _enum;
			}
		}
		return null;
	}
	
	/**
	 * 获取全部枚举
	 * 
	 * @return List<JMXEnum>
	 */
	public List<StateType> getAllEnum() {
		List<StateType> list = new ArrayList<StateType>();
		for (StateType _enum : values()) {
			list.add(_enum);
		}
		return list;
	}
	
	/**
	 * 获取全部枚举值
	 * 
	 * @return List<String>
	 */
	public List<String> getAllEnumCode() {
		List<String> list = new ArrayList<String>();
		for (StateType _enum : values()) {
			list.add(_enum.code());
		}
		return list;
	}
}
